<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
     var frame = document.createElement('iframe'),
         flag = false;
         frame.src = "http://www.jsplusplus.com/index.html";
         frame.style.display = 'none';

         document.body.appendChild(frame); 
         function getData(){
             if(flag){
                var data = frame.contentWindow.name;
                  console.log(data);
             }else{
                flag = true;
                frame.contentWindow.location.href="index2.html" 
             }
         }

         if(frame.attachEvent){
             frame.attachEvent('onload',getData);
         }else{
             frame.onload = getData
         }
         

    </script>
</body>
</html>